﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data;

namespace BanHangCshap.Class.gkhtdl63.DAL
{
    public abstract class DieukienBaohanhDAL : clsBaseDAL
    {
        /// <summary>
        /// Lấy danh sách điều kiện bảo hành
        /// </summary>
        /// <returns>Trả về một Datatable các điều kiện bảo hành</returns>
        public DataTable DieukienBaohanh_LayDanhsach()
        {
            return base.Select("sp_DieukienBaohanh_LayDanhsach");
        }

        public DataTable DieukienBaohanh_LayTheoma(string xlMa)
        {
            string xlSPName = "sp_DieukienBaohanh_LayTheoma";
            string[] xlSPPara = { "@Ma"};
            string[] xlSPValu = { xlMa};
            return base.Select(xlSPName, xlSPPara, xlSPValu);
        }

        public bool DieukienBaohanh_Xoa(string xlMa)
        {
            string xlSPName = "sp_DieukienBaohanh_Xoa";
            string[] xlSPPara = { "@Ma"};
            string[] xlSPValu = { xlMa};
            return base.Delete(xlSPName, xlSPPara, xlSPValu);
        }


        public bool DieukienBaohanh_Them(DAL.Entities.DieukienBaohanh xlDKBH)
        {
            string xlSPName = "sp_DieukienBaohanh_Them";
            string[] xlSPPara = {   "@Ma"
                                    ,"@Ten"
                                    ,"@Mota"
                                    ,"@Ghichu"
                                };

            object xlGhichu = System.Data.SqlTypes.SqlString.Null;
            if (xlDKBH.Ghichu != null)
            {
                xlGhichu = xlDKBH.Ghichu;
            }

            object[] xlSPValu = {   xlDKBH.Ma
                                    ,xlDKBH.Ten
                                    ,xlDKBH.Mota
                                    ,xlGhichu
                                 };
            return base.Insert(xlSPName, xlSPPara, xlSPValu);
        }

        public bool DieukienBaohanh_Capnhat(string xlMacu, DAL.Entities.DieukienBaohanh xlDKBH)
        {
            string xlSPName = "sp_DieukienBaohanh_Capnhat";
            string[] xlSPPara = {   "@Macu"
                                    ,"@Ma"
                                    ,"@Ten"
                                    ,"@Mota"
                                    ,"@Ghichu"
                                };

            object xlGhichu = System.Data.SqlTypes.SqlString.Null;
            if (xlDKBH.Ghichu != null)
            {
                xlGhichu = xlDKBH.Ghichu;
            }

            object[] xlSPValu = {   xlMacu
                                    ,xlDKBH.Ma
                                    ,xlDKBH.Ten
                                    ,xlDKBH.Mota
                                    ,xlGhichu
                                 };
            return base.Update(xlSPName, xlSPPara, xlSPValu);
        }
    }
}
